// Copyright 2011 George Cook
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#import <Foundation/Foundation.h>
#import "InjectiveObjectDescription.h"
#import "InjectiveFactory.h"
@class InjectivePropertyDescription;

@protocol InjectiveInjectionType;
@protocol InjectiveCache;

@interface InjectiveContainer : NSObject {
	NSMutableDictionary *objectDescriptions;
	NSMutableDictionary *objectDescriptionsByID;
	NSMutableDictionary *objectDescriptionsByType;
	NSMutableDictionary *objectDescriptionByClazzLookupCache;

	InjectiveFactory *instanceFactory;
	id<InjectiveCache> instanceCache;
	BOOL hasRetrievedInstances; //this is used so we can prevent overrides once we start instantiating.
}

@property (nonatomic, retain, readwrite) InjectiveFactory *instanceFactory;
@property (nonatomic, retain) id<InjectiveCache> instanceCache;

- (void) addObject:(InjectiveObjectDescription *) objectDescription;
- (void) wireInstance:(id)instance;

- (id) getObject:(id)clazz;
- (id) getObjectByID:(NSString *)ID;
- (id) getObjectByPropertyDescription:(InjectivePropertyDescription *)propertyDescription;

- (void) clearContext;  //Supports unit testing... Only call this if you know what you're doing!
- (void) addInstance: (id)instance;
- (void) addInstance:(id)instance forType:(id)type;

- (NSArray *)objectDescriptionsInContext; //returns the objectdescriptions in the context

//this method is very useful for overriding your prod context, for test/simulator versions
- (void) addObject:(InjectiveObjectDescription *)objectDescription overrideIfIdsAreEqual:(BOOL) isOverriding;


@end